package com.example.example02;

import java.io.IOException;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

public class SpeakDurationReducer extends Reducer<Text,SpeakBean,Text,SpeakBean>{
  private final SpeakBean speakBean = new SpeakBean();

  @Override
  public void reduce(Text key,Iterable<SpeakBean> values,Context context) throws IOException, InterruptedException{
    for(SpeakBean sbItm : values){
      speakBean.setSelfDuration(speakBean.getSelfDuration() + sbItm.getSelfDuration());
      speakBean.setThirdPartDuration(speakBean.getThirdPartDuration() + sbItm.getThirdPartDuration());
      speakBean.setSumDuration(speakBean.getSelfDuration() + speakBean.getThirdPartDuration());
    }
    context.write(key, speakBean);
  }
}
